package onion.molingo2o.activity.service;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListView;
import android.widget.TextView;

import com.easemob.chatuidemo.ui.BaseActivity;

import java.util.ArrayList;
import java.util.List;

import onion.molingo2o.R;
import onion.molingo2o.adapter.OnionAdapter;
import onion.molingo2o.bean.RequestSimple;
import onion.molingo2o.bean.ServerItemSetting;
import onion.molingo2o.views.GridViewWithHeaderAndFooter;

/**
 * Created by Administrator on 2015/11/14.
 */
public class MyServerSettingActivity extends BaseActivity {
    GridViewWithHeaderAndFooter GridView_bottom;
            GridView GridView_top;
    View headView;
    OnionAdapter adapter,topadapter;
    List<ServerItemSetting> listtop=new ArrayList<>();
    List<ServerItemSetting> listbottom=new ArrayList<>();
    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_requestlist);
        initTitle("", "我的服务","");
        headView=View.inflate(this,R.layout.myserversetting_headview,null);
        GridView_bottom= (GridViewWithHeaderAndFooter) findViewById(R.id.server_gridview);
        GridView_bottom.addHeaderView(headView);
        GridView_top= (GridView) headView.findViewById(R.id.myserver_gridview);
        topadapter=new OnionAdapter(this,R.layout.item_serversetting,listtop,new String[]{"title"},new String[]{"getIcon"});
        adapter=new OnionAdapter(this,R.layout.item_serversetting,listbottom,new String[]{"title"},new String[]{"getIcon"});
        GridView_top.setAdapter(topadapter);
        GridView_bottom.setAdapter(adapter);
        GridView_bottom.setOnItemClickListener(bottomItemClickListener);
        GridView_top.setOnItemClickListener(topItemClickListener);
//        listView_bottom.setOnItemClickListener(onItemClickListener);
        getTest();
    }

    AdapterView.OnItemClickListener topItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
           //调用接口，判断是否能够删除  存在进行中的订单，店铺不可删除

        }
    };
    AdapterView.OnItemClickListener bottomItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //进入申请页
            startActivity(new Intent(MyServerSettingActivity.this,RegServerActivity.class));
        }
    };
    private void getTest() {
        for(int i=0;i<5;i++){
            listtop.add(new ServerItemSetting("http://img4.imgtn.bdimg.com/it/u=3320670811,1178842717&fm=21&gp=0.jpg","租房","简单描述"));
        }
        for(int i=0;i<5;i++){
            listbottom.add(new ServerItemSetting("http://pic.nipic.com/2007-11-09/2007119122519868_2.jpg","融资","简单描述"));
        }
        topadapter.notifyDataSetChanged();
        adapter.notifyDataSetChanged();
    }
//    AdapterView.OnItemClickListener onItemClickListener=new AdapterView.OnItemClickListener() {
//        @Override
//        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//            startActivity(new Intent(MyServerSettingActivity.this,ResponDetailActivity.class));
//        }
//    };
}